<template>
  <el-form-item
    :label="labelRuleValue.title"
    :prop="propValue"
    :rules="
      requirsd(labelRuleValue.type)
        ? [
            {
              required: labelRuleValue.rule == 'required' ? true : false,
              message: labelRuleValue.title + $t('common.common33'),
              trigger: 'change',
            },
          ]
        : null
    "
  >
    <el-select
      :value="String(value)"
      :disabled="disabledValue"
      clearable
      @change="handleValue"
    >
      <el-option
        v-for="(item, index) in labelRuleValue.content"
        :key="index"
        :value="String(item.value)"
        :label="item['title_' + $store.state.settings.langTail]"
      ></el-option>
    </el-select>
  </el-form-item>
</template>
<script>
export default {
  name: "selectTag",
  props: {
    value: {
      type: [String, Number], //对应值
      default: "",
    },
    propValue: {
      type: String,
      default: "",
    },
    labelRuleValue: {
      type: Object,
      default: function () {
        return {};
      },
    },
    disabledValue: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    requirsd(type) {
      return !["array", "json"].includes(type);
    },
    handleValue(val) {
      this.$emit("update:value", val);
    },
  },
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.el-select {
  width: 100%;
}
</style>